<template>
  <div>
    <el-drawer
      :visible.sync="visible"
      @open="handleOpen"
      @close="handleClose"
      :size="'480px'"
    >
      <div slot="title" class="align-cm">
        <b class="fc-gray10">会话存档</b>
      </div>
      <iframe
        :src="srcIframe"
        width="100%"
        height="97%"
        frameborder="0"
      ></iframe>
      <!-- <pre>{{ formatParameter }}</pre> -->
      <!-- <pre>{{ tempData }}</pre> -->
      <!-- {{ msgList }} -->
      <!-- <WxMsg :msgList="msgList"></WxMsg> -->
    </el-drawer>
  </div>
</template>

<script>
import { bus } from '@/main.js';
import { mapState, mapMutations } from 'vuex';
export default {
  name: 'theSessionFile', //会话存档
  mixins: [],
  components: {},
  data() {
    return {
      isDev: process.env.NODE_ENV == 'development',
      visible: false,
      tempData: null,
      msgList: [],
      srcIframe: '',
    };
  },
  computed: {
    ...mapState(['userInfo', 'conditional', 'drawer']),
  },
  methods: {
    init: function(tempDate) {
      this.visible = true;
      this.tempData = tempDate;
      this.$nextTick(() => {
        this.ajaxData(true);
      });
      // return;
    },
    handleOpen: function() {},
    handleClose: function() {
      console.log('清空');
      this.srcIframe = '';
    },
  },
  mounted: function() {
    // this.$api.getQiniuToken().then((res) => {
    //   if (res.code == 200) {
    //     this.qiniu.token = res.data;
    //   }
    // });
    bus.$on('调用会话存档', e => {
      let eS_Company_Id = this._.get(e, 'eS_Company_Id', ''); //企业微信id
      let external_userid = this._.get(e, 'external_userid', ''); //发送用户id
      let addTime = this.$moment(this._.get(e, 'addTime', '')).valueOf(); //Long	否	开始时间 ms单位（13位的时间戳）

      let qs = this.$qs.stringify({
        eS_Company_Id: eS_Company_Id,
        external_userid: external_userid,
        addTime: addTime,
      });
      let wl = window.location;
      this.visible = true;

      this.srcIframe = `${wl.origin}${wl.pathname}#/dialogueHistory?${qs}`;

      // this.init(e);
    });
  },
};
</script>

<style scoped lang="less">
.content {
  max-width: 80%;
  padding: 4px 8px;
  border-radius: 16px;
  background-color: #e6f7ff;
}
</style>
